/*
 * 
 * PanjatPinangGLES1
 * State_Gameplay.java
 * Pratama Wijaya
 * set.mnemonix@gmail.com
 * 12:18:08 AM , Jul 12, 2012
 */
package com.amikomgamedev.panjatpinangGLES1.states;

import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.engine.camera.Camera;
import org.anddev.andengine.engine.options.EngineOptions;
import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
import org.anddev.andengine.engine.options.resolutionpolicy.FillResolutionPolicy;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.sprite.Sprite;
import org.anddev.andengine.entity.util.FPSLogger;
import org.anddev.andengine.opengl.texture.Texture;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.opengl.texture.region.TextureRegion;
import org.anddev.andengine.opengl.texture.region.TextureRegionFactory;
import org.anddev.andengine.ui.activity.BaseGameActivity;

import com.amikomgamedev.panjatpinangGLES1.Config;

public class State_Gameplay extends BaseGameActivity {

	private Camera mCamera;
	private Scene mScene;

	private Texture bgTexture;
	private TextureRegion bgTextureReg;
	private Sprite bgSprite;

	@Override
	public void onLoadComplete() {
		// TODO Auto-generated method stub

	}

	@Override
	public Engine onLoadEngine() {
		// TODO Auto-generated method stub
		mCamera = new Camera(0, 0, Config.GAME_SCREEN_WIDTH,
				Config.GAME_SCREEN_HEIGHT);
		EngineOptions engine = new EngineOptions(true,
				ScreenOrientation.PORTRAIT, new FillResolutionPolicy(), mCamera);
		return new Engine(engine);
	}

	@Override
	public void onLoadResources() {
		// TODO Auto-generated method stub

		bgTexture = new Texture(1024, 1024,
				TextureOptions.BILINEAR_PREMULTIPLYALPHA);
		TextureRegionFactory.setAssetBasePath("gfx/ingame/");

		bgTextureReg = TextureRegionFactory.createFromAsset(bgTexture, this,
				"img/Main_back.png", 0, 0);
		this.mEngine.getTextureManager().loadTexture(bgTexture);

	}

	@Override
	public Scene onLoadScene() {
		// TODO Auto-generated method stub
		this.mEngine.registerUpdateHandler(new FPSLogger());

		mScene = new Scene(1);

		bgSprite = new Sprite(0, 0, bgTextureReg);

		mScene.getFirstChild().attachChild(bgSprite);
		return mScene;
	}

}
